package com.ruoyi.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.SaleAnalyse01;
import com.ruoyi.system.service.ISaleAnalyse01Service;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 库存报表Controller
 * 
 * @author ruoyi
 * @date 2024-05-08
 */
@RestController
@RequestMapping("/system/kucun")
public class SaleAnalyse01Controller extends BaseController
{
    @Autowired
    private ISaleAnalyse01Service saleAnalyse01Service;

    /**
     * 查询库存报表列表
     */
    @PreAuthorize("@ss.hasPermi('system:kucun:list')")
    @GetMapping("/list")
    public TableDataInfo list(SaleAnalyse01 saleAnalyse01)
    {
        startPage();
        List<SaleAnalyse01> list = saleAnalyse01Service.selectSaleAnalyse01List(saleAnalyse01);
        return getDataTable(list);
    }

    /**
     * 导出库存报表列表
     */
    @PreAuthorize("@ss.hasPermi('system:kucun:export')")
    @Log(title = "库存报表", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SaleAnalyse01 saleAnalyse01)
    {
        List<SaleAnalyse01> list = saleAnalyse01Service.selectSaleAnalyse01List(saleAnalyse01);
        ExcelUtil<SaleAnalyse01> util = new ExcelUtil<SaleAnalyse01>(SaleAnalyse01.class);
        util.exportExcel(response, list, "库存报表数据");
    }

    /**
     * 获取库存报表详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:kucun:query')")
    @GetMapping(value = "/{stuffId}")
    public AjaxResult getInfo(@PathVariable("stuffId") Long stuffId)
    {
        return success(saleAnalyse01Service.selectSaleAnalyse01ByStuffId(stuffId));
    }

    /**
     * 新增库存报表
     */
    @PreAuthorize("@ss.hasPermi('system:kucun:add')")
    @Log(title = "库存报表", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SaleAnalyse01 saleAnalyse01)
    {
        return toAjax(saleAnalyse01Service.insertSaleAnalyse01(saleAnalyse01));
    }

    /**
     * 修改库存报表
     */
    @PreAuthorize("@ss.hasPermi('system:kucun:edit')")
    @Log(title = "库存报表", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SaleAnalyse01 saleAnalyse01)
    {
        return toAjax(saleAnalyse01Service.updateSaleAnalyse01(saleAnalyse01));
    }

    /**
     * 删除库存报表
     */
    @PreAuthorize("@ss.hasPermi('system:kucun:remove')")
    @Log(title = "库存报表", businessType = BusinessType.DELETE)
	@DeleteMapping("/{stuffIds}")
    public AjaxResult remove(@PathVariable Long[] stuffIds)
    {
        return toAjax(saleAnalyse01Service.deleteSaleAnalyse01ByStuffIds(stuffIds));
    }
}
